import React, { useEffect, useState } from 'react'
import { Descriptions, Col, Row, } from "antd";
import { Decimal } from 'decimal.js';

export default function MemberInfo(props) {
  const data = props.orderInfo // 组件传参
  const [payWay, setPayWay] = useState()
  useEffect(() => {
    if (data) {
      let txt = ''
      switch (data.payWay) {
        case 'WeChat':
          txt = '微信'
          break;
        case 'Alipay':
          txt = '支付宝'
          break;
        case 'UnionPay':
          txt = "银联"
          break;
        default:
          txt = "未知支付方式"
      }
      setPayWay(txt)
    }
  }, [data])
  return (
    <div>
      <Descriptions style={{ marginTop: 20 }} layout="vertical" bordered column={4}>
        <Descriptions.Item label="收货人信息">
          <Row>
            <Col  >收货人：</Col>
            <Col >{data.memberName}</Col>
          </Row>
          <Row>
            <Col  >联系电话：</Col>
            <Col >{data.memberPhone}</Col>
          </Row>
          <Row>
            <Col >收货地址：</Col>
            <Col >{data.memberAddress}</Col>
          </Row>
        </Descriptions.Item>
        <Descriptions.Item label="付款信息">
          <Row>
            <Col >付款方式：</Col>
            <Col >{payWay}</Col>
          </Row>
          <Row>
            <Col >付款时间：</Col>
            <Col >{data.payTime}</Col>
          </Row>
        </Descriptions.Item>
        <Descriptions.Item label="买家信息">
          <Row>
            <Col >买家ID：</Col>
            <Col >{data.memberId}</Col>
          </Row>
          <Row>
            <Col >买家昵称：</Col>
            <Col >{data.buyerName}</Col>
          </Row>
        </Descriptions.Item>
        <Descriptions.Item label="订单金额">
          <Row>
            <Col >订单实付金额：</Col>
            <Col >{data.orderPayPrice ? '￥' + Decimal(data.orderPayPrice).div(Decimal(100)).toNumber().toFixed(2) : '￥0.00'}</Col>
          </Row>
          <Row>
            <Col >订单退款金额：</Col>
            <Col >{data.orderSalesReturnPrice ? '￥' + Decimal(data.orderSalesReturnPrice).div(Decimal(100)).toNumber().toFixed(2) : '￥0.00'}</Col>
          </Row>
          <Row>
            <Col >商家所得：</Col>
            <Col >{data.practicalStorePrice ? '￥' + Decimal(data.practicalStorePrice).div(Decimal(100)).toNumber().toFixed(2) : '￥0.00'}</Col>
          </Row>
          <Row>
            <Col >平台所得：</Col>
            <Col >{data.practicalCommission ? '￥' + Decimal(data.practicalCommission).div(Decimal(100)).toNumber().toFixed(2) : '￥0.00'}</Col>
          </Row>
        </Descriptions.Item>
      </Descriptions>
    </div>
  )
}
